<!-- 回款任务 -->
<template>
  <div class='payment_arrival'>
    <Button class="action" type="primary"> <a
        href="https://images.tospurfang.com/doc/%E5%9B%9E%E6%AC%BE%E4%BB%BB%E5%8A%A1%E6%93%8D%E4%BD%9C%E8%AF%B4%E6%98%8E.pdf"
        style="color:#fff;" target="_blank">查看操作指引</a>
    </Button>
    <Tabs ref="nav" type="card" v-model="paymentShowTab" :animated="false">
      <TabPane label="待完成" name="paymentTaskagency">
        <payment-task-agency ref="agency" v-if="paymentShowTab == 'paymentTaskagency'" />
      </TabPane>
      <TabPane label="已完成" name="paymentTaskDoneAgency">
        <payment-task-done-agency ref="doneAgency"
          v-if="paymentShowTab == 'paymentTaskDoneAgency'" />
      </TabPane>
    </Tabs>
  </div>
</template>

<script>
  import paymentTaskAgency from './component/paymentTask/paymentTaskagency.vue'
  import paymentTaskDoneAgency from './component/paymentTask/paymentTaskDoneAgency.vue'
  import detailPage from '@/views/casemanagement/allCustomersManagement/details.vue'
  import dt from '@dt/dt'
  export default {
    components: {
      paymentTaskAgency,
      paymentTaskDoneAgency,
      detailPage,
    },
    data() {
      return {
        paymentShowTab: 'paymentTaskagency',
      }
    },
    watch: {
      paymentShowTab(val, oldVal) {
        dt.memory.remove('payment_params')
      },
    },
    beforeRouteEnter(to, from, next) {
      if (from.name != 'contractDetail') dt.memory.remove('payment_params')
      next()
    },
    beforeRouteLeave(to, from, next) {
      if (to.name === 'contractDetail') {
        if (this.paymentShowTab == 'paymentTaskagency') {
          this.$refs.agency.retainParamsFun()
        } else {
          this.$refs.doneAgency.retainParamsFun()
        }
      } else {
        dt.memory.remove('payment_params')
      }
      next()
    },
    created() {
      this.paymentShowTab =
        dt.memory.get('payment_params') &&
        dt.memory.get('payment_params').paymentShowTab ?
        dt.memory.get('payment_params').paymentShowTab :
        'paymentTaskagency'
      // 首页跳转
      if (Object.keys(this.$route.params).length) {
        this.paymentShowTab = this.$route.params.showTab
      }
    },
    mounted() {},
  }
</script>
<style lang='scss' scoped>
  .payment_arrival {
    padding: 20px;
    position: relative;

    ::v-deep .ivu-tabs-bar {
      padding-left: 20px;
    }

    .action {
      position: absolute;
      top: 10px;
      right: 10px;
      z-index: 99999;
    }
  }
</style>